﻿using System;
using System.Collections.Generic;
using System.Text;

using System.Net;
using System.Windows.Forms;

namespace siguo_shrx.client
{
    public class Client
    {
        public void DownLoadIPinfo()
        {
            try
            {
                WebClient webClient = new WebClient();
                webClient.DownloadFile("http://shrx.5x5x.info/info/game/junqi/ServerIP.html", "IPinfo.ini");
            }
            catch (Exception)
            {
                throw new Exception("更新服务器IP错误");
            }
        }

        public string GetIP()
        {
            StringBuilder temp = new StringBuilder(255);
            NetApi.GetPrivateProfileString("ServerIP", "IP", "服务器IP读取错误", temp, 255, Application.StartupPath + "\\IPinfo.ini");//Application.StartupPath 需要System.Windows.Forms命名空间
            return temp.ToString();
        }

        public string GetPort()
        {
            StringBuilder temp = new StringBuilder(255);
            NetApi.GetPrivateProfileString("ServerIP", "Port", "服务器端口读取错误", temp, 255, Application.StartupPath + "\\IPinfo.ini");//Application.StartupPath 需要System.Windows.Forms命名空间
            return temp.ToString();
        }
    }
}
